package com.io.example.demoparent.ES.es;


import com.io.example.demoparent.ES.util.ESUtil;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.indices.CreateIndexRequest;
import org.elasticsearch.client.indices.CreateIndexResponse;

import java.io.IOException;

/*
     创建索引
 */
public class ES_Index_Create {

    public static void main(String[] args) throws IOException {
        RestHighLevelClient client = ESUtil.esRestClient( );
        //创建索引
        CreateIndexRequest createIndexRequest = new CreateIndexRequest("user");
        CreateIndexResponse response = client.indices( ).create(createIndexRequest, RequestOptions.DEFAULT);
        //响应状态
        boolean acknowledged = response.isAcknowledged( );

        System.out.println("响应状态 = " + acknowledged);

        client.close();
    }
}
